{% extends 'task_market/base.html' %}
{% load static %}
{% block title %}
    质量检测
{% endblock %}
{% block content %}

    <div class="breadcrumbs">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="bread-inner">
                        <ul class="bread-list">
                            <li><a href="{% url 'task_market:index' %}" target="_blank">主页<i
                                    class="ti-arrow-right"></i></a></li>
                            <li class="active"><a href="#">质量检测</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="container mt-4 mx-auto">
        <div class="row">
            <div class="col-lg-12">
                <div class="account-content">
                    <h4 class="account-content-title"><i class="far fa-user"></i> 任务信息({{ task.task_name }})</h4>
                    <div class="profile-info">
                        <div class="row">
                            <div class="col-lg-7 mx-auto">
                                <div class="row">
                                    <div class="col-lg-4 mb-1">
                                        <div class="profile-widget">
                                            <b>{{ all_assign_num }}</b>
                                            <p>任务内容总计</p>
                                        </div>
                                    </div>
                                    <div class="col-lg-4 mb-1">
                                        <div class="profile-widget">
                                            <b>{{ anno_assign_num }}</b>
                                            <p>已标注数量统计</p>
                                        </div>
                                    </div>
                                    <div class="col-lg-4 mb-1">
                                        <div class="profile-widget">
                                            <b>{{ perc_anno }}</b>
                                            <p>完成进度</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="profile-details">
                        <div class="row">
                            <div class="col-lg-1 mx-auto">
                                <p>任务ID</p>
                                <h6>{{ task.id }}</h6>
                            </div>
                            <div class="col-lg-1 mx-auto">
                                <p>发布者ID</p>
                                <h6>{{ task.task_publish_id|truncatechars:8 }}</h6>
                            </div>
                            <div class="col-lg-1 mx-auto">
                                <p>任务类型</p>
                                {% if task.task_type == '1' %}
                                    <h6>文本分类</h6>
                                {% elif task.task_type == '4' %}
                                    <h6>图像分类</h6>
                                {% elif task.task_type == '5' %}
                                    <h6>图像标选</h6>
                                {% endif %}
                            </div>
                            <div class="col-lg-3 mx-auto">
                                <p>任务描述</p>
                                <h6>{{ task.task_description }}</h6>
                            </div>
                            <div class="col-lg-1 mx-auto">
                                <p>任务等级</p>
                                <h6>{{ task.task_rank }}</h6>
                            </div>
                            {% if task.task_status == 4 %}
                                <div class="col-lg-2 mx-auto">
                                    <p>确认</p>
                                    <h6><a href="{% url 'manager:confirm' task_id=task_id %}"
                                           class="content-action content-action-mr"><i
                                            class="far"> 确认</i></a><a href="{% url 'manager:cancel' task_id=task_id %}"
                                                                        class="content-action content-action-mr"><i
                                            class="far"> 取消</i></a></h6>
                                </div>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <section class="shop section">

        <div class="container">
            <div class="row">
                <div class="col-lg-12 mx-auto">
                    <div class="account-content">
                        <h4 class="account-content-title"><i class="far fa-shopping-bag"></i>质量检测表</h4>
                        <div class="row align-items-center">
                            <div class="col-md-auto">
                                <label for="show_items">抽检条数：</label>
                            </div>
                            <div class="col-md-auto">
                                <form method="get" action="{% url 'manager:check_score' id=task_id %}">
                                    <select name="show_items" id="show_items" onchange="this.form.submit()">
                                        <option value="10" {% if show_items == 10 %}selected{% endif %}>10条</option>
                                        <option value="20" {% if show_items == 20 %}selected{% endif %}>20条</option>
                                        <option value="50" {% if show_items == 50 %}selected{% endif %}>50条</option>
                                    </select>
                                </form>
                            </div>
                        </div>
                        <div class="account-content-table">
                            <div class="table-responsive">
                                <table class="table table-borderless">
                                    <tr>
                                        <th>数据内容</th>
                                        <th>标注结果</th>
                                        <th>标注者ID</th>
                                        <th>打分</th>
                                    </tr>
                                    <form method="post" action="{% url 'manager:check_score' id=task_id %}">
                                        {% csrf_token %}
                                        {% for data in taskdata %}
                                            <tr class="account-order-list order-single-product">
                                                {% if task.task_type == '1' %}
                                                    <td>
                                                        <div class="product-info">{{ data.taskdata_content|truncatechars:30 }}</div>
                                                    </td>
                                                {% elif task.task_type == '4' or task.task_type == '5' %}
                                                    <td>
                                                        <div class="product-info"><img
                                                                src="http://localhost:8000/images/{{ data.taskdata_content }}"
                                                                width="60">
                                                        </div>
                                                    </td>
                                                {% endif %}
                                                {% if task.task_type == '1' %}
                                                    <td>
                                                        <div class="product-info">{{ data.taskdata_result|truncatechars:30 }}</div>
                                                    </td>
                                                {% elif task.task_type == '4' or task.task_type == '5' %}
                                                    <td>
                                                        <div class="product-info">{{ data.taskdata_result }}</div>
                                                    </td>
                                                {% endif %}

                                                <td>
                                                    <div class="product-info">{{ data.taskdata_assign }}</div>
                                                </td>
                                                <td>
                                                    <input type="number" name="scores[]" min="0" max="100" required>
                                                </td>
                                            </tr>

                                        {% endfor %}
                                </table>
                                <div class="text-center">
                                    <button class="btn" type="submit">提交 <i
                                            class="fal fa-paper-plane"></i></button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </section>

{% endblock %}